Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Backport] Fix for #16069: Configurable product price is not displayed if all children are out of stock and even if Display Out of Stock Products is set to "yes" #18776 #18739

Closed
wants to merge 7 commits into from

Conversation

vpodorozh
Copy link
Contributor

@vpodorozh vpodorozh commented Oct 22, 2018

Original Pull Request

#18776

Description (#16069)

Configurable product price is not displayed if all children are out of stock and even if Display Out of Stock Products is set to "yes"

Fixed Issues

  1. Configurable product price is not displayed if all children are out of stock and even if Display Out of Stock Products is set to "yes" #16069: Configurable product price is not displayed if all children are out of stock and even if Display Out of Stock Products is set to "yes"

Preconditions

  1. Magento CE 2.2.2 with Sample Data
  2. PHP 7.0

Manual testing scenarios

  1. Create configurable product with view simples
  2. Make configurable and all simple products out of stock
  3. Set Display Out of Stock Products to "yes"

Expected result

Price for configurable product should be displayed

Actual result

Price is not displayed at all

Contribution checklist

  • Pull request has a meaningful description of its purpose
  • All commits are accompanied by meaningful commit messages
  • All new or changed code is covered with unit/integration tests (if applicable)
  • All automated tests passed successfully (all builds on Travis CI are green)

…ldren are out of stock and even if Display Out of Stock Products is set to "yes"

- allow "out of stock" items to be used for price determination of configurable product ONLY in case all child products are "out of stock".
…ldren are out of stock and even if Display Out of Stock Products is set to "yes"

- add strict types.
@vpodorozh
Copy link
Contributor Author

@novikor - please review

@vpodorozh vpodorozh self-assigned this Oct 22, 2018
@novikor novikor assigned novikor and vpodorozh and unassigned vpodorozh and novikor Oct 22, 2018
@vpodorozh vpodorozh assigned vpodorozh and novikor and unassigned novikor and vpodorozh Oct 22, 2018
Copy link
Contributor

@novikor novikor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a blank line (comment is left near needed piece of code).

…ldren are out of stock and even if Display Out of Stock Products is set to "yes"

- refactor variable names.
…ldren are out of stock and even if Display Out of Stock Products is set to "yes"

- add blank space.
*/
protected function isApplySalableCheck(SaleableInterface $salableItem): bool
{
return (bool)$salableItem;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Object will be always converted to true, isn't it?

Copy link
Contributor Author

@vpodorozh vpodorozh Oct 22, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I’ve missed it. This method from Catalog module should always return true.
Will change it tomorrow.

In general this method was added to make it possible to skip salable check in child classes without need to rewrite _toHtml method.

Copy link
Contributor Author

@vpodorozh vpodorozh Oct 22, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@orlangur - I've removed unneeded usage of the variable ( check this https://github.com/magento/magento2/pull/18739/files/f4ec67e5aada173a27586131598d5b24957472d6#diff-5f0a1c702f3ad19b38e301107e2852daR97 ). However, there was a need to add @SuppressWarnings(PHPMD.UnusedFormalParameter) phpdoc for isApplySalableCheck method to make it pass static tests.

Goal of this method isApplySalableCheck: make price rendering depending not only on isSalable check but also on addaitional check that can be modified in child classes without need to rewrite _toHtml method.
I've used this "newly added" posibility in this class Magento\ConfigurableProduct\Pricing\Render\FinalPriceBox

An other way to achieve this goal is to rewrite _toHtml method that will require a big amount of copy&paste code due to private properties and methods usage.

So I do prefer currently implemented solution.

…ldren are out of stock and even if Display Out of Stock Products is set to "yes"

- remove unneeded usage of the variable.
@magento-engcom-team magento-engcom-team added Partner: ISM eCompany Pull Request is created by partner ISM eCompany partners-contribution Pull Request is created by Magento Partner labels Oct 22, 2018
@magento-engcom-team
Copy link
Contributor

Hi @vpodorozh. Thank you for your contribution
Here is some useful tips how you can test your changes using Magento test environment.
Add the comment under your pull request to deploy test or vanilla Magento instance:

  • @magento-engcom-team give me test instance - deploy test instance based on PR changes
  • @magento-engcom-team give me $VERSION instance - deploy vanilla Magento instance

For more details, please, review the Magento Contributor Assistant documentation

@magento-cicd2
Copy link
Contributor

magento-cicd2 commented Oct 22, 2018

CLA assistant check
All committers have signed the CLA.

…ldren are out of stock and even if Display Out of Stock Products is set to "yes"
@vpodorozh
Copy link
Contributor Author

@magento-engcom-team give me test instance

@magento-engcom-team
Copy link
Contributor

Hi @vpodorozh. Thank you for your request. I'm working on Magento instance for you

@magento-engcom-team
Copy link
Contributor

Hi @vpodorozh, here is your new Magento instance.
Admin access: http://ec2-34-228-235-121.compute-1.amazonaws.com/pr-18739//admin
Login: admin Password: 123123q

@vpodorozh
Copy link
Contributor Author

@orlangur - could you please review my PR?

@orlangur orlangur self-assigned this Nov 7, 2018
@orlangur orlangur changed the title 2.2 develop #16069 [Backport] Fix for #16069: Configurable product price is not displayed if all children are out of stock and even if Display Out of Stock Products is set to "yes" #18776 Nov 7, 2018
@VladimirZaets
Copy link
Contributor

Hi @vpodorozh. The branch 2.2-develop will be closed for contribution from July 15, 2019. Please finish all your Pull Requests till this date, otherwise, they will be closed.
Thanks for collaboration.

@orlangur
Copy link
Contributor

Closing as corresponding 2.3 PR is closed.

@orlangur orlangur closed this Jul 15, 2019
@m2-assistant
Copy link

m2-assistant bot commented Jul 15, 2019

Hi @vpodorozh, thank you for your contribution!
Please, complete Contribution Survey, it will take less than a minute.
Your feedback will help us to improve contribution process.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants